OpenRoads Designer CONNECT Edition SDK Help

Rename feature names used in DGN

The below code snippet shows renaming the existing feature name with new name for point, alignment, profile, and corridor.

//Required References
using Bentley.CifNET.GeometryModel.SDK;
using Bentley.CifNET.SDK.Edit;

public void RenameFeatureName()
        {
            //Get active DGN model connection for edit purpose  
            Bentley.CifNET.SDK.Edit.ConsensusConnectionEdit con = ConsensusConnectionEdit.GetActive();
            if (con == null) return;

            //Get active geometric model
            GeometricModel activeGM = con.GetActiveGeometricModel();

            //Rename point feature
            foreach (PointEntity2d point in activeGM.PointEntities2d)
            {
                if (point != null)
                {
                    //Rename point feature name, this is for OpenRoads Designer version 10.11 
                    //bool status = point.SetFeatureDefinition("PointRenamed");

                    //Rename point feature name, this is for OpenRoads Designer version 10.12 and above
                    bool status = point.SetFeatureDefinition("Point\\Existing\\Right of Way\\E_Existing_RW", "PointRenamed");
                    break;
                }
            }


            //Rename alignment
            foreach (Alignment alignment in activeGM.Alignments)
            {
                if (alignment != null && alignment.IsFinalElement)
                {
                    //Rename alignment feature name
                    string renamedName = alignment.SetName("AlignmentRenamed");
                    break;
                }
            }

            //Rename profile
            foreach (Alignment alignment in activeGM.Alignments)
            {
                if (alignment != null && alignment.IsFinalElement)
                {
                    foreach (Profile profile in alignment.Profiles)
                    {
                        if (profile.IsFinalElement)
                        {
                            string name = profile.Name;
                            //Rename profile feature name
                            bool status = profile.SetFeatureDefinition("Alignment\\Geom_Baseline", "ProfileRenamed");
                            break;
                        }
                    }
                }
            }

            //Rename corridor
            foreach (Corridor corridor in activeGM.Corridors)
            {
                if (corridor != null)
                {
                    //rename corridor feature name with "CorridorRenamed"
                    corridor.FeatureName = "CorridorRenamed";
                    break;

                }
            }
        }